import {
	BillType_Home,
	BillType_Detail,
	BillType_History,
	BillType_Month,
	Bill_List
} from "../../Action/bill/billAction";
import objectAssign from "object-assign";
import {isServer} from "../../../tools/utils";
const billReducerData = isServer ? {}: sessionStorage.getItem("billReducerData")
	? JSON.parse(sessionStorage.getItem("billReducerData"))
	: {};
const billReducer = (state = billReducerData, action) => {
	switch (action.type) {
		case BillType_Home:
			sessionStorage.setItem(
				"billReducerData",
				JSON.stringify(objectAssign({}, state, action.data))
			);
			return objectAssign({}, state, action.data);
		case BillType_Detail:
			return objectAssign({}, state, action.data);
		case BillType_History:
			return objectAssign({}, state, action.data);
		case BillType_Month:
			return objectAssign({}, state, action.data);
		case Bill_List:
			return objectAssign({}, state, action.data);
		default:
			return state;
	}
};

export default billReducer;
